home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / f2c / may_5_92.lha / f2c.VMay_5_1992 / libI77 / util.c < prev    next >
C/C++ Source or Header  |  1992-05-07  |  1KB  |  54 lines

  1. #ifndef MSDOS
  2. #include "sys/types.h"
  3. #include "sys/stat.h"
  4. #endif
  5. #include "f2c.h"
  6. #include "fio.h"
  7.  
  8. g_char(a,alen,b) char *a,*b; ftnlen alen;
  9. {
  10.     char *x = a + alen, *y = b + alen;
  11.  
  12.     for(;; y--) {
  13.         if (x <= a) {
  14.             *b = 0;
  15.             return;
  16.             }
  17.         if (*--x != ' ')
  18.             break;
  19.         }
  20.     *y-- = 0;
  21.     do *y-- = *x;
  22.         while(x-- > a);
  23.     }
  24.  
  25. b_char(a,b,blen) char *a,*b; ftnlen blen;
  26. {    int i;
  27.     for(i=0;i<blen && *a!=0;i++) *b++= *a++;
  28.     for(;i<blen;i++) *b++=' ';
  29. }
  30. #ifndef MSDOS
  31. long inode(a, dev) char *a; int *dev;
  32. {    struct stat x;
  33.     if(stat(a,&x)<0) return(-1);
  34.     *dev = x.st_dev;
  35.     return(x.st_ino);
  36. }
  37. #endif
  38.  
  39. #define INTBOUND sizeof(int)-1
  40. mvgbt(n,len,a,b) char *a,*b;
  41. {    register int num=n*len;
  42.     if( ((int)a&INTBOUND)==0 && ((int)b&INTBOUND)==0 && (num&INTBOUND)==0 )
  43.     {    register int *x=(int *)a,*y=(int *)b;
  44.         num /= sizeof(int);
  45.         if(x>y) for(;num>0;num--) *y++= *x++;
  46.         else for(num--;num>=0;num--) *(y+num)= *(x+num);
  47.     }
  48.     else
  49.     {    register char *x=a,*y=b;
  50.         if(x>y) for(;num>0;num--) *y++= *x++;
  51.         else for(num--;num>=0;num--) *(y+num)= *(x+num);
  52.     }
  53. }
  54.